<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *提现记录
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$tabs=array(
);

//提现记录
if($_RQ['op']=='list'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['name'])){
		$params['name like']='%'.trim($_RQ['name']).'%';
		$return['params']['name']=$_RQ['name'];
	}
	if(!empty($_RQ['logsn'])){
		$params['logsn']=trim($_RQ['logsn']);
		$return['params']['logsn']=$_RQ['logsn'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','mid','type','title','createtime','status','logsn','money','rechargetype','rechargemoney','couponid','deductionmoney','remark','realname','bankname','bankcard');
	$list=pdo_getslice('jy_weishop_member_log',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$member=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['mid']));
			$item['nickname']=$member['nickname'];
			$item['avatar']=$member['avatar'];
		}
	}
	
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'logsn','title'=>'单号','type'=>'string'),
			array('name'=>'avatar','title'=>'用户头像','type'=>'image'),
			array('name'=>'nickname','title'=>'用户昵称','type'=>'string'),
			array('name'=>'realname','title'=>'真实姓名','type'=>'string'),
			array('name'=>'money','title'=>'提现金额','type'=>'string'),
			array('name'=>'createtime','title'=>'提现时间','type'=>'string'),
			array('name'=>'rechargetype','title'=>'提现方式','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		)),
		'action' => 
		    array (
		          
		           array('title'=>'微信钱包','type'=>'post','op'=>'wechat','message'=>'确认拒绝该提现申请吗','show'=>array('status'=>0)),
		           array('title'=>'手动提现','type'=>'post','op'=>'tixian','message'=>'手动提现该提现申请吗','show'=>array('status'=>0)),
		           array('title'=>'拒绝','type'=>'post','op'=>'refuse','message'=>'确认拒绝该提现申请吗','show'=>array('status'=>0)),
		        ),  
		'search'=>array(
			array('name'=>'logsn','width'=>15,'title'=>'单号','type'=>'string'),
		)
	);
	
	$return['status']=array('0'=>'申请中','1'=>'已完成','2'=>'已拒绝');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_weishop_member_log',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}

if($_RQ['op']=='refuse'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('该提现申请不存在！','error');	
	}
	$this->update('jy_weishop_member_log',array('status'=>2),array('id'=>$id));
	exi('已拒绝该提现申请');
}